﻿using System;
using System.Collections.Generic;
using System.Text;

namespace CSTest.DefaultInterfaceMethod
{
    public class SampleCustomer : ICustomer
    {
        public SampleCustomer(string name, DateTime dateJoined) =>
              (Name, DateJoined) = (name, dateJoined);

        private List<IOrder> allOrders = new List<IOrder>();

        public IEnumerable<IOrder> PreviousOrders => allOrders;

        public DateTime DateJoined { get; }

        public DateTime? LastOrder { get; private set; }

        public string Name { get; }

        private Dictionary<DateTime, string> reminders = new Dictionary<DateTime, string>();
        public IDictionary<DateTime, string> Reminders => reminders;

        IEnumerable<IOrder> ICustomer.PreviousOrders => throw new NotImplementedException();

        DateTime ICustomer.DateJoined => throw new NotImplementedException();

        DateTime? ICustomer.LastOrder => throw new NotImplementedException();

        string ICustomer.Name => throw new NotImplementedException();

        IDictionary<DateTime, string> ICustomer.Reminders => throw new NotImplementedException();

        public void AddOrder(IOrder order)
        {
            if (order.Purchased > (LastOrder ?? DateTime.MinValue))
                LastOrder = order.Purchased;
            allOrders.Add(order);
        }

        public decimal ComputeLoyaltyDiscount()
        {
            if (allOrders.Count > 233)
            {
                return ICustomer.DefaultLoyaltyDiscount(this);
            }
            else
            {
                return 0;
            }
        }

        public void OriginDemo()
        {
            throw new NotImplementedException();
        }

        public void OriginDemo2()
        {
            throw new NotImplementedException();
        }

        void ICustomer.OriginDemo()
        {
            throw new NotImplementedException();
        }

        void ICustomer.OriginDemo2()
        {
            throw new NotImplementedException();
        }

        void ICustomer.ProtectDemo()
        {
            throw new NotImplementedException();
        }
    }

    public class SampleOrder : IOrder
    {
        public SampleOrder(DateTime purchase, decimal cost) =>
            (Purchased, Cost) = (purchase, cost);

        public DateTime Purchased { get; }

        public decimal Cost { get; }
    }
}
